package models;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import play.db.ebean.Model;

@Entity
public class ProvaAlunoQuestao extends Model{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public long id;
	
	@ManyToMany(cascade=CascadeType.MERGE, fetch=FetchType.EAGER)
	@JoinTable(name="ProvaAluno_Opcao_Escolhida", joinColumns = { @JoinColumn(name = "provaalunoquestao_id") }, inverseJoinColumns = { @JoinColumn(name = "opcao_id") })
	public List<Opcao> respostaaluno = new ArrayList<Opcao>();
	
	public boolean correta;
	
	public double notaMax;

	public double notaObtida;
	
	@Temporal(TemporalType.TIMESTAMP)
	public Date dtAlteracao;
	
	public int ordem;
	
	@Temporal(TemporalType.DATE)
	public Date dtCadastro;
	// ------------------relacionamentos---------------------//
	@ManyToOne
	public ProvaAluno provaaluno;
	
	@ManyToOne
	public Questao questao;
}
